import type { SizeType } from 'ant-design-vue/es/config-provider';
import { SYS_THEME } from './enum/system';
const modules = import.meta.glob('./views/admin/modules/*/*.vue');
interface pageConfig {
  componentSize: SizeType;
  algorithm: any;
  lang: any;
}
interface DynamicComponents {
  [key: string]: {
    component: any;
    path: string;
  };
}
export const localComponents = ref<DynamicComponents>({});

export const pageConfig = ref<pageConfig>({
  componentSize: 'middle',
  algorithm: SYS_THEME.LIGHT,
  lang: undefined,
});

Object.keys(modules).forEach((path: string) => {
  for (const path in modules) {
    const result = path.match(/.*\/(.+).vue$/);
    let componentPath: any = result?.[1];
    if (result) {
      const component: any = modules[path];
      localComponents.value[componentPath] = {
        component,
        path: componentPath,
      };
    }
  }
});
